/**
 * 
 */
package net.homelinux.ajay.net.ondisk.view.menu.client;


import net.homelinux.ajay.net.ondisk.view.client.AppTree;
import net.homelinux.ajay.net.ondisk.view.client.CollectionsTreeItem;
import net.homelinux.ajay.net.ondisk.view.client.CommandsMenu;
import net.homelinux.ajay.net.ondisk.view.client.NamedCommand;
import net.homelinux.ajay.net.ondisk.view.dialogs.client.AddCollectionDialog;

/**
 * @author ajay
 *
 */
public class CollectionsMenuBuilder extends MenuBuilder {

  private static CollectionsMenuBuilder instance;


  /**
   * @param tree
   */
  public CollectionsMenuBuilder() {
    super();
  }

  public CommandsMenu makeContextMenu()
  {
    CommandsMenu contextMenu = super.makeContextMenu();
    if(contextMenu==null){
      contextMenu = new CommandsMenu();
    }
    contextMenu.addCommand(new NamedCommand("Add Collection",null){

      public void execute() {
        System.out.println("Executing Named Command :"+ getName());
        CollectionsTreeItem parent = (CollectionsTreeItem) getTree().getSelectedItem();
        AddCollectionDialog.makeDialog().show(parent);
      }});
//    
//    contextMenu.addCommand(new NamedCommand("Add URL", null){
//
//      public void execute() {
//        System.out.println("Executing Named Command :"+ getName());
//        //CollectionTreeItem.this.
//      }});
    
    contextMenu.addCommand(new NamedCommand("<hr/>", null){

      public void execute() {
        // NOOP
        
      }});
//    contextMenu.addCommand(new NamedCommand("Delete Collection", null){
//
//      public void execute() {
//        System.out.println("Executing Named Command :"+ getName());
//        //CollectionTreeItem.this.
//      }});
    return contextMenu;
    
  }


  public static CollectionsMenuBuilder getInstance() {
    if(instance == null){
      instance = new CollectionsMenuBuilder();
    }
    return instance;
  }

}
